package cocurrency.semaphore;

import java.util.concurrent.Semaphore;

/**
 * Created by luzl on 4/6/2017.
 */
public class SemaphoreThread extends  Thread{

    private Semaphore semaphore;
    private String name;

    public SemaphoreThread(String name,Semaphore semaphore){
        this.name=name;
        this.semaphore=semaphore;
    }
    public void run(){
            try {
                semaphore.acquire();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(this.name+" Get Semaphore, Begin to Run");
            semaphore.release();
    }
}
